using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Reflection;
using FluentNHibernate.Cfg.Db;
using NHibernate.Driver;
using NHibernate.SqlTypes;
using Orchard.Environment.Extensions;

namespace Orchard.Contrib.Modules.NHibSecondLevelCache.Data.Providers
{
    [OrchardSuppressDependency("Orchard.Data.Providers.SqlCeDataServicesProvider")]
    [Serializable]
    public class SqlCeDataServicesProvider : AbstractDataServicesProvider {
        private Orchard.Data.Providers.SqlCeDataServicesProvider _base;

        public SqlCeDataServicesProvider(string dataFolder, string connectionString) {
            _base = new Orchard.Data.Providers.SqlCeDataServicesProvider(dataFolder, connectionString);
        }

        public SqlCeDataServicesProvider(string fileName) {
            _base = new Orchard.Data.Providers.SqlCeDataServicesProvider(fileName);
        }

        public static string ProviderName {
            get { return Orchard.Data.Providers.SqlCeDataServicesProvider.ProviderName; }
        }

        public override IPersistenceConfigurer GetPersistenceConfigurer(bool createDatabase) {
            var persistence = _base.GetPersistenceConfigurer(createDatabase) as MsSqlCeConfiguration;
            return persistence.Cache(cache => cache.ProviderClass<NHibernate.Caches.SysCache.SysCacheProvider>());            
        }

       
    }
}
